package com.trippin.DB.entities;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import javax.jdo.annotations.PersistenceCapable;

import com.google.gson.annotations.Expose;

@PersistenceCapable
public class UserNotification<T> implements TrippinEntity, Serializable {
	
	private static final long serialVersionUID = 1L;
	
	public enum NotificationType {
		USERS_NEAR_ME("usersNearMe"),
		ATTRACTIONS_YOU_MAY_LIKE("attractionsYouMayLike"),
		TRIP_SHARING("TripSharing");		
		
		private final String name;
		
		private NotificationType(String name) {
			this.name = name;
		}
		
		public String getName() {
			return name;
		}				
	}

	/*
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	*/
	
	@Expose
	private long userId;
	
	@Expose
	private int newNotifications;
	
	@Expose
	private String type;
	
	@Expose
	private List<T> notifications;
	
	
	public UserNotification(long userId, NotificationType type, List<T> notifications) {
		this.userId = userId;
		this.notifications = new LinkedList<T>(notifications);
		this.newNotifications = notifications.size();
		this.type = type.getName();
	}

	/*
	public Key getKey() {
		return key;
	}
	*/
	
	public long getUserId() {
		return userId;
	}
	
	public int getNewNotifications() {
		return newNotifications;
	}

	public void setNewNotifications(int newNotifications) {
		this.newNotifications = newNotifications;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<T> getNotifications() {
		return notifications;
	}

	public void setNotifications(List<T> notifications) {
		this.notifications = notifications;
	}
}
